#include <iostream>

using namespace std;
//结构体做函数参数:将结构体作为参数向函数中传递

//传递方式有两种:
//1、值传递
//2、址传递

//定义学生的结构体
struct Student {
    string name;//姓名
    int age;//年龄
    int score;//分数
};


//1、值传递
void print1(Student student) {
    cout << "学生的姓名为" << student.name << ",年龄为" << student.age << ",分数为" << student.score << endl;
}

//2、址传递
void print2(struct Student *student) {
    cout << "学生的姓名为" << student->name << ",年龄为" << student->age << ",分数为" << student->score << endl;
}

int main() {
    //创建结构体变量
    struct Student student;
    student.name = "张三";
    student.age = 18;
    student.score = 95;
    print1(student);
    print2(&student);
    return 0;
}
//如果不想修改主函数中的数据，用值传递，反之用地址传递